package com.dragon.modules.yuegou.enums.member;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * openid类型
 * 
 * @author pbuilder generated
 *
 */
public enum WxOpenidRefOpenIdType {

	/**
	 * 悦购小程序
	 */
	YGIRL(0, "悦购小程序"),
	/**
	 * 悦荷包小程序
	 */
	WALLET(1, "悦荷包小程序"),
	/**
	 * 悦商圈公众号
	 */
	YSQ(2, "悦商圈公众号"),
	/**
	 * 安卓APP
	 */
	ANDRIOD(3, "安卓APP"),
	/**
	 * IOS
	 */
	IOS(4, "IOS"),
	/**
	 * 支付宝
	 */
	ALIPAY(5, "支付宝"),
	/**
	 * 答题小程序
	 */
	TCXDT(6, "答题小程序"),
	/**
	 * 支付宝小程序
	 */
	ALIXCX(7, "支付宝小程序"),

	UNIAPP(8, "UNIAPP");

	/**
	 * 枚举标识
	 */
	private final Integer code;

	/**
	 * 别名
	 */
	private final String alias;

	private WxOpenidRefOpenIdType(Integer code, String alias) {
		this.code = code;
		this.alias = alias;
	}
	
	public Integer getValue() {
		return code;
	}

	/**
	 * 枚举标识
	 * 
	 * @return code
	 */
	public Integer getCode() {
		return code;
	}

	/**
	 * 别名
	 * 
	 * @return alias
	 */
	public String getAlias() {
		return alias;
	}

	/**
	 * 把code转化为费用类型枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	@JsonCreator
	public static WxOpenidRefOpenIdType from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for WxOpenidRefOpenIdType
	 */
	private static final Map<Integer, WxOpenidRefOpenIdType> CODE_MAP = Stream.of(WxOpenidRefOpenIdType.values())
			.collect(Collectors.toMap(WxOpenidRefOpenIdType::getCode, e -> e));

}
